<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title>{&SITE_TITLE}</title>
                <link href="__PUBLIC__/admin/css/layout.css" rel="stylesheet" type="text/css" />
                <script type="text/javascript" src="__PUBLIC__/js/jquery.js" ></script>

                <script type="text/javascript">
                        $( function(){
                                $( "select[name='sorder']" ).val("{$sorder}");
                                $( "select[name='eorder']" ).val("{$eorder}");
                                $( "select[name='limit']" ).val("{$limit}");
                        });
                        var ctrl = function(name){
                                this.elements = document.getElementsByName('id[]');
                                this.length = this.elements.length;
                        }
                        ctrl.prototype = {
                                reverse:function(){
                                        for(i=0;i<this.length;i++){
                                                this.elements[i].checked= !this.elements[i].checked;
                                        }
                                },
                                all:function(){
                                        for(i=0;i<this.length;i++){
                                                this.elements[i].checked = true;
                                        }
                                },
                                unAll:function(){
                                        for(i=0;i<this.length;i++){
                                                this.elements[i].checked = false;
                                        }
                                },
                                toggle:function(obj){
                                        this[obj.checked ? 'all' : 'unAll']();
                                },
                                del:function(id){
                                        if(id==undefined){
                                                id = [];
                                                for(i=0;i<this.length;i++){
                                                        this.elements[i].checked && id.push(this.elements[i].value);
                                                }
                                                id = id.join(',');
                                        }
                                        if( confirm( "是否删除投票") ){
                                                $.post( '__URL__/doDeleteVote/',{id:id},function(text ){
                                                        if( text == 1 ){
                                                                alert( "删除成功" );
                                                                var id_list = id.split( ',' );
                                                                for (var j=0 ; j< id_list.length ; j++   ){
                                                                        $( 'tr['+'id=\'vote'+id_list[j]+'\']' ).remove();
                                                                }
                                                        }else if( text == 2 ){
                                                                $( 'tr['+'id=\'vote'+id+'\']' ).remove();
                                                        }else{
                                                                alert( "删除失败" );
                                                        }
                                                });
                                        }
                                },
                                edit:function(id,act){
                                        if( act == "recommend" ){
                                                v = "取消推荐";
                                        }else{
                                                v= "设置推荐";
                                        }
                                        if( confirm( '是否'+v ) ){
                                                $.post( '__URL__/doChangeIsHot',{id:id,act:act},function( text ){
                                                        if( text == 1 ){
                                                                alert( "操作成功" );
                                                                $( '#button'+id ).val( v );
                                                                //kattr( 'onclick', "c.edit"+id+",'"+act+"')")
                                                        }else{
                                                                alert( "设置失败" );
                                                        }
                                                });
                                        }
                                }
                        }
                        var c = null;
                </script>
        </head>
        <body>
                <div id="container">
                        <div class="tab">
                                <ul>
                                        <li> <a href="__URL__/index/">全局设置</a></li>
                                        <li><a   class="on"  href="__URL__/votelist/">投票管理</a></li>
                                </ul>
                        </div>
                        <table class="tableborder" width="100%">
                                <tbody>
                                        <tr class="top">
                                                <td class="border"></td>
                                        </tr>
                                        <tr>
                                                <th class="header">tips</th>
                                        </tr>
                                        <tr>
                                                <td class="tips">
                                                        <ul>
                                                                <li></li>
                                                                <li></li>
                                                                <li></li>
                                                                <li></li>
                                                        </ul>
                                                </td>
                                        </tr>
                                        <tr class="bottom">
                                                <td class="border" colspan="5">&nbsp;</td>
                                        </tr>
                                </tbody>
                        </table>

                        <form action = "" method="post">
                                <table class="tableborder" width="100%">
                                        <tbody>
                                                <tr class="top">
                                                        <td class="border" colspan="2"></td>
                                                </tr>
                                                <tr>
                                                        <th class="header" colspan="2">查询</th>
                                                </tr>
                                                <tr class="label">
                                                        <th>说明</th>
                                                        <th>设置</th>
                                                </tr>
                                                <tr class="cell">
                                                        <td class="altbg1">
                                                                <b>用户名:</b>
                                                                <br/>
                                                                <span class="smalltxt">根据用户名查询</span>
                                                        </td>
                                                        <td class="altbg2"><input name="name" class="txt" value="{$name}"/></td>
                                                </tr>
                                                <tr class="cell">
                                                        <td class="altbg1">
                                                                <b>用户Id</b>
                                                                <br/>
                                                                <span class="smalltxt">根据用户id</span>
                                                        </td>
                                                        <td class="altbg2"><input name="uid" class="txt" value="{$uid}"/></td>
                                                </tr>

                                                <tr class="cell">
                                                        <td class="altbg1">
                                                                <b>投票标题</b>
                                                                <br/>
                                                                <span class="smalltxt">根据投票标题,支持模糊查询。</span>
                                                        </td>
                                                        <td class="altbg2"><input name="title" class="txt" value="{$title}"/></td>
                                                </tr>

                                                <tr class="cell">
                                                        <td class="altbg1">
                                                                <b>发表时间</b>
                                                                <br/>
                                                                <span class="smalltxt">根据发表时间(格式YYMMDD),支持YYMM月份搜索,例：2009年5月1号请输入:20090501.2009年5月:200905</span>
                                                        </td>
                                                        <td class="altbg2">开始时间:<input name="stime" class="txt" value="{$stime}"/>
                                                                <br />
                                                                结束时间:<input name="etime" class="txt" value="{$etime}"/></td>
                                                </tr>

                                                <tr class="cell">
                                                        <td class="altbg1">
                                                                <b>结果排序</b>
                                                                <br/>
                                                        </td>
                                                        <td class="altbg2">
                                                                <select name="sorder">
                                                                        <option value = "cTime" selected>时间排序</option>
                                                                        <option value = "id">发布id排序</option>
                                                                        <option value = "name">发布者排序</option>
                                                                </select>
                                                                <select name="eorder">
                                                                        <option value = "DESC" selected>降序</option>
                                                                        <option value = "ASC" >升序</option>
                                                                </select>
                                                                <select name="limit">
                                                                        <option value = "10" selected>每页显示10条</option>
                                                                        <option value = "20">每页显示20条</option>
                                                                        <option value = "30">每页显示30条</option>
                                                                        <option value = "100">每页显示100条</option>
                                                                </select>
                                                        </td>
                                                </tr>
                                                <tr>
                                                        <td class="footer" colspan="2">
                                                                <input type="submit" class="submit" value="提交" />
                                                        </td>
                                                </tr>
                                        </tbody>
                                </table>
                        </form>
                        <table class="tableborder" width="100%">
                                <tbody>
                                        <tr class="top">
                                                <td class="border" colspan="6"></td>
                                        </tr>
                                        <tr>
                                                <th class="header" colspan="6">标题</th>
                                        </tr>
                                        <tr class="label">
                                                <th><input type="checkbox" class="checkbox" onclick="c.toggle(this)" />删？</th>
                                                <th>编号</th>
                                                <th>发起人</th>
                                                <th>发起标题</th>
                                                <th>发帖时间</th>
                                                <th>操作</th>
                                        </tr>
                                        <volist name="data" id='vo'>
                                                <tr class="cell altbg1" id="vote{$vo['id']}">
                                                        <td><input type="checkbox" class="checkbox" name="id[]" value="{$vo['id']}" /></td>
                                                        <td>{$i}</td>
                                                        <td>{$vo['name']}</td>
                                                        <td><a href="__APP__/Index/pollDetail/id/{$vo['id']}">{$vo['title']}</a></td>
                                                        <td>{$vo['cTime']|friendlyDate}</td>
                                                        <td><input type="button" onclick="c.del({$vo['id']})" value="删除" /></td>
                                                </tr>
                                        </volist>
                                        <tr>
                                                {$html}
                                        </tr>
                                        <tr>
                                                <td class="footer" colspan="6">
                                                        <button type="button" onclick="c.all()">全选</button>
                                                        <button type="button" onclick="c.unAll()">全不选</button>
                                                        <button type="button" onclick="c.reverse()">反选</button>
                                                        <button type="button" onclick="c.del()">删除</button>
                                                </td>
                                        </tr>
                                        <tr class="bottom">
                                                <td class="border" colspan="6">&nbsp;</td>
                                        </tr>
                                </tbody>
                        </table>
                </div>
                <script type="text/javascript">
                        c = new ctrl('id[]');
                </script>
        </body>
</html>
